package com.sg.hms.Util;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;


public class JDBCUtil {
	 private final  static String url="jdbc:mysql://localhost:3306/hms?useUnicode=true&characterEncoding=UTF-8"
	 		+ "";
     private final static  String userName="root";
     private final static String passWord = "123123";
     public static Connection getConnection(){
	   	  Connection con = null;
	   	  try {
				Class.forName("com.mysql.jdbc.Driver");
				con=DriverManager.getConnection(url, userName, passWord);
				
			} catch (ClassNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}    	  
	   	  
	   	  return con;
     }
     public void closeJDBC(PreparedStatement pst,Connection con){
    	
		 try {
			 if(pst!=null){
			    pst.close();
			 }
			 if(con!=null){
				 con.close();
			 }
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
    	
     }
}
